(ns conducta.login-sample
  (:use conducta.bdd conducta.ui))

(User-story "As a system user, I want to be able to submit my credentials, so that I can access my account.")

(defn Enter-credentials-submit-enabled-scenario
    "The 'Submit' button is disabled by default. When the user types in their username and password, the 'Submit' button turns enabled."  
    [username password role signin]
    
    (Given "that the sign-in button is disabled")
    (verify-disabled! signin)
  
    (When "username and password are typed in")
    (enter-text "bobsmith" username)
    (enter-text "bobspassword" password)
    
    (And "user is selected")
    (verify-selected! "Administrator" role)
    (select "User" role)
    (verify-selected! "User" role)
  
    (Then "sign-in button should become disabled")
    (verify-enabled! signin)
)


(defn Login-button-disabled-on-clearing-scenario
  "Having enabled the 'Submit' button on entering username and the password, the user deletes the username. The 'Submit' button must then turn back to disabled"
  [username password signin]
  
  (verify-disabled! signin)
  (enter-text "bobsmith" username)
  
  (When "password is entered and then removed")
  (enter-text "bobspassword" password)
  (delete-text password)
  
  (Then "sign-in button should turn disabled")
  (verify-disabled! signin)
)

(defn User-cancels-login-scenario
  "'Cancel' button is enabled whether we have a username or password entered."
  [username password cancel]
  
  ;; No Given/When/Then words are used
  (verify-enabled! cancel)
  (enter-text "bobsmith" username)
  (verify-enabled! cancel)
  (delete-text username)
  (verify-enabled! cancel)
  (enter-text "bobspassword" password)
  (verify-enabled! cancel)
  (delete-text password)
  (type-key "shift P" username)
  (press-key "R" username)
  (release-key "R" username)
  (verify-enabled! cancel)
  
  (click cancel)
  (double-click cancel)
  (right-click cancel)
  (left-click cancel)
  (middle-click cancel)
)

;; more scenarios to follow ...


